import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '名称',
    align: 'left',
    dataIndex: 'name'
   },
   {
    title: '编码',
    align: 'center',
    dataIndex: 'code'
   },
   {
    title: '描述',
    align: 'center',
    dataIndex: 'description'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '父级节点',
    field: 'pid',
    component: 'JTreeSelect',
    componentProps: {
      dict: "t_classification,name,id",
      pidField: "pid",
      pidValue: "0",
      hasChildField: "has_child",
    },
  },
  {
    label: '作物分类',
    field: 'associateId',
    component: 'JTreeSelect',
    componentProps: {
      dict: "t_classification,name,id",
      pidField: "pid",
      pidValue: "1690901276535795713",
      hasChildField: "has_child",
      multiple: true,
      // treeCheckAble: true,
      // converIsLeafVal: 1
    },
    ifShow: ({ values }) => {
      // console.log(values)
      return values.pid == '1689815136974086145';
    },
  },
  {
    label: '名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({}) => {
      return [
        { required: true, message: '请输入名称!'},
      ];
    },
  },
  {
    label: '编码',
    field: 'code',
    component: 'Input',
    dynamicRules: ({}) => {
      return [
        { required: true, message: '请输入编码'},
      ];
    },
  },
  {
    label: '描述',
    field: 'description',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

//排产新增表单数据
export const takeFormSchema: FormSchema[] = [
  {
    label: '名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({}) => {
      return [
        { required: true, message: '请输入名称!'},
      ];
    },
  },
  // {
  //   label: '编码',
  //   field: 'code',
  //   component: 'Input',
  //   dynamicRules: ({model,schema}) => {
  //     return [
  //       { required: true, message: '请输入编码'},
  //     ];
  //   },
  // },
  {
    label: '',
    field: 'pid',
    defaultValue: '1689815136974086145',
    component: 'Input',
    show: false
  },
  {
    label: '',
    field: 'associateId',
    component: 'Input',
    show: false
  },
]

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
